package com.car.loan.project.xr.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.Collection;
import java.util.List;


import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.car.loan.project.xr.mapper.LoanStatusMapper;
import com.car.loan.project.xr.domain.LoanStatus;
import com.car.loan.project.xr.service.ILoanStatusService;

/**
 * 业务状态Service业务层处理
 *
 * @author ruoyi
 * @date 2019-11-03
 */
@Service
public class LoanStatusServiceImpl implements ILoanStatusService {

    @Autowired
    private LoanStatusMapper loanStatusMapper;

    /**
     * 查询业务状态
     *
     * @param id 业务状态ID
     * @return 业务状态
     */
    @Override
    public LoanStatus selectLoanStatusById(Long id) {
        return loanStatusMapper.selectById(id);
    }

    @Override
    public Optional<LoanStatus> getByLoanId(long loanId) {
        return loanStatusMapper.selectByLoanId(loanId);
    }

    /**
     * 查询业务状态列表
     *
     * @param loanStatus 业务状态
     * @return 业务状态
     */
    @Override
    public List<LoanStatus> selectLoanStatusList(LoanStatus loanStatus) {
        QueryWrapper<LoanStatus> queryWrapper = new QueryWrapper<>(loanStatus);
        return loanStatusMapper.selectList(queryWrapper);
    }


    @Override
    public IPage<LoanStatus> selectPage(IPage<LoanStatus> page,
        QueryWrapper<LoanStatus> queryWrapper) {
        return loanStatusMapper.selectPage(page, queryWrapper);
    }

    /**
     * 新增业务状态
     *
     * @param loanStatus 业务状态
     * @return 结果
     */
    @Override
    public int insertLoanStatus(LoanStatus loanStatus) {

        return loanStatusMapper.insert(loanStatus);
    }

    /**
     * 修改业务状态
     *
     * @param loanStatus 业务状态
     * @return 结果
     */
    @Override
    public int updateLoanStatus(LoanStatus loanStatus) {

        return loanStatusMapper.updateById(loanStatus);
    }

    /**
     * 删除业务状态对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLoanStatusByIds(Collection<Long> ids) {
        return loanStatusMapper.deleteBatchIds(ids);
    }

    /**
     * 删除业务状态信息
     *
     * @param id 业务状态ID
     * @return 结果
     */
    @Override
    public int deleteLoanStatusById(Long id) {
        return loanStatusMapper.deleteById(id);
    }
}
